package com.cat.greedyAlgorithm;

import java.io.*;

/**
 * @author 曲大人的喵
 * @description https://ac.nowcoder.com/acm/contest/119225/A
 * @create 2025/10/12 19:01
 * @since JDK17
 */

public class Solution86 {
    static int N = ((int) (1e9 + 7)), n, m;


    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // 接收输入
        in.nextToken();
        n = ((int) in.nval);
        int ans = 0, sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        out.println(sum % 9);

        br.close();
        out.flush();
        out.close();
    }
}
